package com.example.hs.Controller;

import com.example.hs.DTO.CategoryDTO;
import com.example.hs.Service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/categories")
public class   CategoryController {
    @Autowired
    private CategoryService categoryService;

    // 获取所有一级分类及其包含的二级分类
    @GetMapping("/all")
    public ResponseEntity<List<CategoryDTO>> getAllFirstLevelCategoriesWithChildren() {
        return ResponseEntity.ok(categoryService.getAllFirstLevelCategoriesWithChildren());
    }
}
